package com.czxy.servlet;

import cn.itcast.servlet.BaseServlet;
import com.czxy.domain.ProductVo;
import com.czxy.service.ProductService;
import com.github.pagehelper.PageInfo;

import javax.servlet.annotation.WebServlet;

@WebServlet("/productServlet")
public class ProductServlet extends BaseServlet {

    // 查询
    public String findProductByVo(){
        //1.接收参数
        ProductVo productVo = toBean(ProductVo.class);
        String pageNum = getRequest().getParameter("pageNum");
        int pageSize = 6;
        //2.调用Service获取结果
        ProductService service = new ProductService();
        PageInfo pageInfo = service.findProductByVo(productVo, Integer.parseInt(pageNum), pageSize);
        //3.把信息存储到request域
        getRequest().setAttribute("pageInfo", pageInfo);
        getRequest().setAttribute("productVo",productVo);

        //4.请求转发给product_list.jsp
        return "/jsp/product_list.jsp";
    }

}
